package com.yugao.fintech.antelope.base.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 存储器类型
 *

 */
@Getter
@AllArgsConstructor
public enum StorageTypeEnum {
    /** 阿里云存储 */
    ALIYUN(ConfigKeyEnum.STORAGE_ALIYUN, "1"),
    /** minio存储 */
    MINIO(ConfigKeyEnum.STORAGE_MINIO, "2"),
    /** 七牛云存储 */
    QINIU(ConfigKeyEnum.STORAGE_QINIU, "3"),

    ;
    private final ConfigKeyEnum bindConfig;
    private final String code;

    public static StorageTypeEnum ofByBindConfig(ConfigKeyEnum configKey) {
        return Arrays.stream(StorageTypeEnum.values()).filter(e -> e.getBindConfig().equals(configKey))
                .findFirst().orElse(null);
    }

    public static StorageTypeEnum ofByBindConfig(String configKey) {
        return Arrays.stream(StorageTypeEnum.values()).filter(e -> e.getBindConfig().getKey().equals(configKey))
                .findFirst().orElse(null);
    }
}
